@import "../../base.less";

@import "./_var.less";

.@{prefix}-search {
  display: flex;
  padding: @search-vertical-padding @search-horizontal-padding;
  background-color: @search-background-color;
  align-items: center;
  box-sizing: border-box;

  &__form {
    position: relative;
    flex: auto;
    background-color: @search-input-background-color;
    border-radius: @search-input-border-radius;
  }

  &__box {
    position: relative;
    width: 100%;
    height: 100%;
    padding-left: 36px;
    padding-right: 32px;
    border-radius: inherit;
    box-sizing: border-box;
    z-index: 1;
  }

  &__label {
    position: absolute;
    display: flex;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    font-size: 0;
    color: @search-placeholder-text-color;
    background-color: @search-input-background-color;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    z-index: 2;

    &-text {
      display: inline-block;
      font-size: @search-placeholder-text-size;
      color: @search-placeholder-text-color;
      margin-left: @search-placeholder-text-margin-left;
      vertical-align: middle;
    }
  }

  &__input {
    font-size: @search-text-size;
    color: @search-text-color;
    width: 100%;
    height: @search-input-height;
    background-color: @search-input-background-color;
    padding: 0 @search-input-horizontal-padding;
    border: 0;

    /* stylelint-disable-next-line */
    input::-webkit-input-placeholder,
    input::placeholder {
      color: @search-placeholder-text-color;
    }

    input::-webkit-search-decoration,
    input::-webkit-search-cancel-button,
    input::-webkit-search-results-button,
    input::-webkit-search-results-decoration {
      display: none;
    }
  }

  &__icon-search {
    position: absolute;
    top: 50%;
    transform: translateX(-100%) translateY(-50%);
    font-size: 24px;
    line-height: 1;
    color: @text-color-placeholder;
  }

  &__label-icon-search {
    font-size: 24px;
    line-height: 24px;
  }

  &__icon-close {
    position: absolute;
    top: 50%;
    transform: translateX(0) translateY(-50%);
    right: 12px;
    font-size: 24px;
    line-height: 1;
    color: @text-color-placeholder;
  }

  &__cancel-button {
    display: none;
    font-size: @search-cancel-button-text-size;
    color: @search-cancel-button-text-color;
    padding: @search-cancel-button-padding;
    margin-left: @search-cancel-button-margin-left;
    margin-right: calc(-1 * @search-cancel-button-margin-left);
  }

  &.@{prefix}-is-focused {

    .@{prefix}-search {
      &__cancel-button {
        display: block;
      }

      &__label {
        display: none;
      }
    }
  }
}
